package vek.controllers.Info;

import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import vek.GUI.Infoview.WebsiteViewer;

/**
 * This class controls the input by the end user in the WebsiteViewer panel.
 * This class handles when a user clicks a hyperlink and makes sure that the WebsiteViewer shows the website the hyperlink links to
 * @author Christian, Michal og Jakob (Hold 1, gruppe 2)
 */
public class WebsiteViwerController implements HyperlinkListener{
    WebsiteViewer wv;
    
    /**
     * updates the WebsiteViewer with the website that the end user is trying to access via a hyperlink.
     * This effectively simulates simply browsing behavior for the JEditorPane
     * @param e the hyperlink event which is generated when the end user clicks on a hyperlink
     */

    public void hyperlinkUpdate(HyperlinkEvent e) {
        try
            {
             if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 
             {
                wv = (WebsiteViewer) e.getSource();
                wv.setPage(e.getURL());
            }
             
                }catch(Exception ex)
                {}
    }

}
